import { defineStore } from 'pinia';

export const useAppStore = defineStore('appStore', {
  state: () => {
    return {
      user: {
        username: JSON.parse(localStorage.getItem('user'))?.username || '',
        avatar: JSON.parse(localStorage.getItem('user'))?.avatar || '',
      },
    };
  },
  getters: {},
  actions: {
    setUser(user) {
      this.user = user;
      localStorage.setItem('user', JSON.stringify(user));
    },
  },
});
